
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <title>API配置</title>
    <link href="/static/devtools30/layui-v2.5.6/css/layui.css" rel="stylesheet" />
    <link href="/static/devtools30/css/devindexbase.css" rel="stylesheet" />
    <script src="/static/devtools30/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui-v2.5.6/layui.all.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/devtoolCommon.js" type="text/javascript"></script>

    <style>
        /*-------------------------tab-------------------------*/

        .layui-tab {
            margin: 0;
        }


        /*边框*/

        .layui-tab-title {
            border-bottom-width: 3px;
            border-bottom-color: #f7f7f7;
        }


        /*字体*/

        .layui-tab-title li {
            font-size: 11px!important;
        }


        /*高度*/

        .tabwrap .layui-tab-title {
            height: 24px;
        }


        /*高度*/

        .tabwrap .layui-tab-title li {
            line-height: 24px;
        }


        /*高度*/

        .tabwrap .layui-tab-title .layui-this:after {
            height: 24px;
        }

        .layui-tab-title .layui-this:after {
            /*height: auto!important;*/
        }


        /*选中时样式*/

        .tabwrap .layui-tab-title .layui-this {
            color: white;
            background: #41BFC0;
        }


        /*关闭按钮样式*/

        .tabwrap .layui-tab-title li .layui-tab-close {
            color: #FFFFFF!important;
        }


        /*顶部搜索容器*/

        .tophead {
            height: 32px;
            /*border-bottom: 1px solid #F7F7F7;*/
            padding: 0 5px;
        }


        /*顶部输入框，下拉框去掉layui默认边距*/

        .tophead .layui-form-item {
            margin-bottom: 0px!important;
        }


        /*顶部输入框，下拉框左边文本样式*/

        .tophead .layui-form-label {
            padding: 0;
            line-height: 25px;
            width: auto;
        }


        /*顶部form块样式*/

        .tophead .layui-input-block {
            margin-left: 34px;
            min-height: 26px;
        }


        /*顶部输入框，下拉框设置高度*/

        .tophead .layui-input,
        .layui-select {
            height: 25px;
        }


        /*顶部下拉框设置子项高度*/

        .tophead .layui-form-select dl {
            top: 26px;
            padding: 0;
        }


        /*顶部下拉框设置子项内容高度*/

        .tophead .layui-form-select dl dd,
        .layui-form-select dl dt {
            line-height: 24px;
        }

        /*顶部下拉框图标大小*/

        .tophead .layui-form-select .layui-edge {
            border-width: 4px;
        }


        /*搜索框左边距*/

        .tophead .search .layui-input-block {
            margin-left: 32px;
        }


        /*表格字体大小*/

        .layui-table td,
        .layui-table th {
            font-size: 11px!important;
        }


        /*表格边距*/

        .layui-table,
        .layui-table-view {
            margin: 0;
        }

        .tab0>li:nth-child(1) .layui-icon.layui-unselect.layui-tab-close {
            display: none;
        }
        .layui-btn {
            height: 26px;
            line-height: 26px;
            font-size: 11px;
        }
    </style>
</head>
<body>
<div>
    <div class="layui-tab tabwrap" lay-allowClose="true" lay-filter="tab" style="border-color: #f7f7f7;border-style: solid;">
        <ul class="layui-tab-title tab0" id="layui-tab-all" style="background: #F5F7FA;">
            <!--三级导航（tab）-->
            <li class="layui-this">全部</li>
        </ul>
        <div class="layui-tab-content content0" style="padding: 0;">
            <!--tab--全部-->
            <div class="layui-tab-item layui-show">
                <div class="flex flex-align-center flex-jusity-betreen tophead backgroundf">
                    <div class="flex flex-align-center">
                        <div class="layui-form flex flex-align-center" lay-filter="formTest">
                            <div class="layui-form-item">
                                <label class="layui-form-label">起始日期</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" name="stdate" id="stdate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">截止日期</label>
                                <div class="layui-input-inline layui-input-wrap">
                                    <input type="text" name="eddate" id="eddate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item marginleft10 search">
                                <label class="layui-form-label">查询</label>
                                <div class="layui-input-block">
                                    <input type="text" name="searchValue" id="searchValue" placeholder="请输入功能ID或代码" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <button type="button" onclick="loaddata()" class="layui-btn layui-btn-sm layui-btn-normal marginleft10">查询</button>
                            <div class="layui-form-item marginleft10 search">
                                <label class="layui-form-label">日志保留天数</label>
                                <div class="layui-input-block" style="margin-left: 76px;">
                                    <input type="text" name="logstoredays" id="logstoredays" autocomplete="off" value="7" class="layui-input">
                                </div>
                            </div>
                            <button type="button" onclick="submitLogStoreDays()"  name="submitlogstoredays" class="layui-btn layui-btn-sm layui-btn-normal marginleft10">确定</button>
                        </div>
                    </div>
                    <div class="layui-btn-group btns tab1">
<!--                        <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" name=''>确定</button>-->
                    </div>
                </div>
                <div style="height:100%;width: 49.99%;background: #F7F7F7;padding: 3px 0;float: left;">
                    <div class="backgroundf">
                        <table id="mygrid" lay-filter="mygrid"></table>
                    </div>
                </div>
                <div style="height:100%;width: 49.99%;background: #F7F7F7;padding: 3px 0;float: right;">
                    <div class="colororange padding100">请求参数</div>
                    <div class="layui-input-block" style="margin-left: 0;width: 100%;height: 100%">
                        <textarea name="reqJson" id="reqJson" placeholder="{}" class="layui-textarea textheight" style="height: 88%"></textarea>
                    </div>
                    <div class="colororange padding100">执行SQL</div>
                    <div class="layui-input-block" style="margin-left: 0;width: 100%;height: 100%">
                        <textarea name="strsql" id="strsql" placeholder="" class="layui-textarea textheight" style="height: 88%"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    var height = dlCommon.getWinHeight();
    var width=dlCommon.getWinWidth();
    var selTableId;
    $(function () {
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1,                      //月份
                "d+": this.getDate(),                           //日
                "H+": this.getHours(),                          //小时
                "m+": this.getMinutes(),                        //分
                "s+": this.getSeconds(),                        //秒
                "q+": Math.floor((this.getMonth() + 3) / 3),    //季度
                "S": this.getMilliseconds()                     //毫秒
            };
            if (/(y+)/.test(fmt))
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt))
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        };
        var currentDate=new Date();
        currentDate.setTime(currentDate.getTime()+86400*1000*1)
        $("#eddate").val(currentDate.Format("yyyy-MM-dd"));
        currentDate.setTime(currentDate.getTime()-86400*1000*2)
        $("#stdate").val(currentDate.Format("yyyy-MM-dd"));
        $("#reqJson").height( height/2-90);
        $("#strsql").height( height/2-90);
        layui.laydate.render({
            elem: '#stdate'
        });
        layui.laydate.render({
            elem: '#eddate'
        });

        loaddata();

        initEvent();

    })

    function loaddata(){
        var data={
            stdate:$("#stdate").val(),
            eddate:$("#eddate").val(),
            searchValue:$("#searchValue").val()
        };

        dlCommon.getJSON("/DevtApiLogEntityController/getList", data, function (data) {
             initGrid(data.data)
        }, true);
    }


    function initGrid(data){
        layui.table.render({
            id:'mygrid',
            elem: '#mygrid',
            height: height-80,
            size: 'sm', //小尺寸的表格
            page: true, //开启分页
            data:data?data:[],
            cols: [
                [ //表头
                    {type: 'checkbox'},
                    { field: 'id', title: 'ID',width: '6%' },
                    { field: 'subdm', title: 'API代码', width: '15%' },
                    { field: 'subname', title: 'API名称', width: '15%' },
                    { field: 'estatus', title: '结果状态', width: '15%' ,templet: function(d){
                            var str=d.estatus=='1'?"失败":"成功";
                            return str;
                        }
                    },
                    { field: 'cdate', title: '请求时间', width: '15%',templet: function(d){
                            var str=new Date(d.cdate).Format("yyyy-MM-dd HH:mm:ss");
                            return str;
                        } },
                    { field: 'opera', title: '操作', width: "15%",templet: function(d){
                            var str="";
                            return str;
                        }
                    }
                ]
            ]
        });

        dlCommon.layerTableOn("mygrid",function(obj){
            selTableId=obj.data.id;
            $("#reqJson").val("");
            $("#strsql").val("");
            $("#reqJson").val(JSON.stringify(JSON.parse(obj.data.jsondata), null, '\t'));
            $("#strsql").val(obj.data.strsql);
        })

    }
    function initEvent(){
        /*按钮点击事件*/
        $('.tab1>button').on('click', function() {
            var names = $(this)[0].name;
            if(names == 'submitlogstoredays') {
                var logstoredays= $("#logstoredays").val()
                dlCommon.getJSON("/DevtApiLogEntityController/submitlogstoredays", {logstoredays:logstoredays}, function (data) {

                }, true);
            }
        })
    }

    function submitLogStoreDays() {
        var logstoredays= $("#logstoredays").val()
        dlCommon.getJSON("/DevtApiLogEntityController/submitlogstoredays", {logstoredays:logstoredays}, function (data) {
            dlCommon.layerSuccess('操作成功!');
            return;
        }, true);
    }


    $(function(){
        /*动态设置iframe高度*/
        var h = document.body.clientHeight
        $('#iframeAll').height(h - 45)

        layui.use('element', function() {
            var element = layui.element;
            element.on('tab(tab)', function(data) {

            });

        });
    })

</script>

</html>